<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>通知</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/member.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<div id="header" style="height: 0.9rem; background: #fff; position: fixed; top: 0;left: 0; width: 100%; z-index: 99">
    <header class="header header-shadow">
        <div class="header-left">
            <div tapmode onclick="comeBack();" class="nav-left"><img class="icon-back" src="../../icon/icon-back.png"/>
            </div>
        </div>
        <h2>通知</h2>
        <!-- <div class="header-right">
            <div class="nav-right c-999"><img style="width: .3rem" src="../../icon/icon-clear2.png" /></div>
        </div> -->
    </header>
</div>
<div class="mescroll" id="mescroll" style="padding-top: 1.5rem">
    <section class="html_section  pl30 pr30">
        <ul class="msg_tz">
            <!-- <li class="pt25 pb25 c-999 f24 t-c">昨天 19:23</li>
            <li class="msg_tz_li">
                 <div class="msg_title_img"><img src="../../icon/msg_logo.png" /></div>
                 <div class="tz_content bb">
                     <div><span tapmode class="c-primary">LUCK-幸运</span>发布新动态</div>
                     <div class="lh40 c-999 f24">无拘无束，自由自在,这才是我所向往的生活，真的希望以后一直都可以这样</div>
                     <div class="between mt10">
                         <span class="c-999 f24">3分钟前</span>
                         <span class="c-primary f24">删除</span>
                     </div>
                 </div>
            </li> -->
        </ul>
    </section>
</div>


</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<link rel="stylesheet" type="text/css" href="../../css/mescroll.min.css"/>
<script type="text/javascript" src="../../script/mescroll.min.js"></script>
<script type="text/javascript">
    apiready = function () {
        setFixStatusBar(); //设置状态栏
        pop.loading();
        keybackListener()
        ready();
    }
    //创建MeScroll对象
    var mescroll = new MeScroll("mescroll", {
        down: {
            auto: false, //是否在初始化完毕之后自动执行下拉回调callback; 默认true
            callback: downCallback //下拉刷新的回调
        }
    });
    /*下拉刷新的回调 */
    function downCallback() {
        ready()

        //mescroll.endErr();
    }

    function ready() {
        getAjax(Interface.get_notice_details, {token: $api.getStorage('token'), type: 1}, function (res) {
            console.log(jsonChange(res))
            pop.close();
            var html = '';
            if(isDefine(res.data)){
                $.each(res.data, function (j, jtem) {
                    $.each(jtem.data, function (i, item) {
                        var member_id = {'member_id': item.pmember_id};
                        var result = getresult(item);
                        // html += '<li id="time_' + item.id + '" class="pt25 pb25 c-999 f24 t-c">' + j + ' ' + item.date_time + '</li>';
                        html += '<li id="data_' + item.id + '" class="msg_tz_li pt20"  >';
                        html += '<div class="msg_title_img bg-cover" onclick=\'commonUrl("../activity/person_index",' + jsonChange(member_id) + ')\' style="background-image: url(' + getImg(item.pmember_path) + ');" ></div>';
                        html += '<div class="tz_content bb">';
                        html += '<div><span tapmode class="c-primary" onclick=\'commonUrl("../activity/person_index",' + jsonChange(member_id) + ')\' >' + item.pmember_name + '</span>' + result.text + '</div>';
                        html += '<div class="lh40 c-999 f24" onclick=\'commonUrl("' + result.url + '",' + jsonChange(result.urlParam) + ')\' >' + item.content + '</div>';
                        html += '<div class="between mt10">';
                        html += '<span class="c-999 f24">' + item.date + ' ' + jtem.date_time + '</span>';
                        html += '<span class="c-primary f24" tapmode onclick="deleteMsg(' + item.id + ')">删除</span>';
                        html += '</div>';
                        html += '</div>';
                        html += '</li>';
                    })
                });

                $(".msg_tz").html(html);
            }else {
                $(".msg_tz").html(noData);
            }

            api.sendEvent({
                name: 'msgStatus',
                extra: {}
            });
            api.sendEvent({
                name: 'tzInfo',
                extra: {}
            });


            mescroll.endErr()
        }, function (res, err) {
            mescroll.endErr()
        })
    }

    var resour_type = ['', '新闻', '帖子', '活动', '评论', '话题'];

    function getresult(item) {
        var leixing = [
            '',
            '给您的' + resour_type[item.resour_type] + '点赞了',
            '回复了您的' + resour_type[item.resour_type],
            '评论了您的' + resour_type[item.resour_type],
            '关注了您',
            '发布了新动态',
            '提到了你，快去看看吧'

        ]
        var url = '';
        var urlParam;
        var result = leixing[item.leixing];
        switch (item.resour_type) {
            case 0:
                if(item.leixing == 4){
                    url = '../member/myFans';
                    urlParam = {};
                }
                break;
            case 1:
                // result = '新闻';
                url = '../index/news_detail';
                urlParam = {'news_id': item.resour_id};
                if (item.leixing == 2) {
                    if(item.comment_id != 0){
                        result = '回复了您的评论';
                        url = '../activity/comment_detail';
                        urlParam = {"id": item.comment_id, detail_id: item.resour_id};
                    }else {
                        result = leixing[item.leixing];
                        url = '../index/news_detail';
                        urlParam = {'news_id': item.resour_id};
                    }
                }
                break;
                break;
            case 2:
                //result = '帖子';
                url = '../circle/invite_detail';
                urlParam = {'invitation_id': item.resour_id};
                if (item.leixing == 2) {
                    if(item.comment_id != 0){
                        result = leixing[item.leixing];
                        url = '../activity/comment_detail';
                        urlParam = {"id": item.comment_id, detail_id: item.resour_id};
                    }else {
                        result = leixing[item.leixing];
                        url = '../circle/invite_detail';
                        urlParam = {'invitation_id': item.resour_id};
                    }
                }
                break;
            case 3:
                //result = '活动';
                url = '../activity/activity_index';
                urlParam = {"activity_id": item.resour_id};
                break;
            case 4:
                //result = '评论';
                url = '../activity/comment_detail';
                urlParam = {"id": item.comment_id, detail_id: item.resour_id};
                //var c_id = {"id": comment[i].id,'detail_id': activity_id};
                break;
            case 5:
                //result = '话题';
                url = '../index/topic_detail';
                urlParam = {"discuss_id": item.resour_id, "today": 2};
                // var param = {"discuss_id": data[i].id, "today": 2};
                break;
        }
        return {
            text: result,
            url: url,
            urlParam: urlParam
        };
    }

    function deleteMsg(id) {
        event.stopPropagation();//  阻止事件冒泡
        confirmBox('删除通知消息', '您确认要删除吗', function () {
            pop.loading();
            getAjax(Interface.notice_del, {token: $api.getStorage('token'), type: 1, notice_id: id}, function (res) {
                pop.close();
                pop.notice('删除成功!');
                $("#data_" + id).addClass("del");
                $("#time_" + id).addClass("del");
                setTimeout(function () {
                    $("#data_" + id).remove();
                    $("#time_" + id).remove();
                }, 1300);
                api.sendEvent({
                    name: 'reload',
                    extra: {}
                });
            }, function (res, err) {
            })
        })
    }


</script>
